package com.springmvc.adapter;

import org.springframework.stereotype.Component;

import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/** Servlet处理器适配器 */
@Component
public class ServletHandlerAdapter implements HandlerAdapter{

    /** 判断当前处理器类型是否为Servlet*/
    @Override
    public boolean support(Object handler) {
        return handler instanceof Servlet;
    }

    /** 执行处理器方法 */
    @Override
    public Object handle(HttpServletRequest req, HttpServletResponse res, Object handler) throws Exception {
        // 以Servlet形式，执行处理器方法
        ((Servlet)handler).service(req, res);

        return null;
    }
}
